<?php

declare (strict_types=1);


namespace app\api\controller;

use app\common\model\News as NewsModel;
use app\common\tool\Result;
use think\facade\View;
use think\Response;

class News extends Base
{
    public function info()
    {
        $id = $this->request->param('id');
        $info = NewsModel::where('id', $id)->find();
        if ($info->status != 1 || $info->is_del) {
            return Result::fail('公告信息错误');
        }
        $info->hits = $info->hits + 1;
        $info->save();
        return Result::success('success', $info);
    }

    public function getList(): Response
    {
        $sys_id = $this->request->param('sys_id',1);
        return Result::fastReturn(NewsModel::getPageList(['sys_id' => $sys_id], 'id,title,images,create_time', $this->getPage()));
    }
}